﻿// <copyright file="admin_Logs_Create.aspx.cs" company="NTalent">
// Copyright (c) 2010, NTalent, Inc. All rights reserved
// </copyright>
// <author>卢俊坤</author>
// <author>王彦博 符茂松</author>

using System;
using Net.Ntalent.Action50.Core.Controls;
using Net.Ntalent.Action50.Core.Service;
using Net.Ntalent.Action50.Core.Util;

/// <summary>
/// 管理页面，为某个action新建log
/// </summary>
///<author>王彦博</author> 
/// <copyright>
/// Copyright (c) 2010, NTalent, Co. Ltd. All rights reserved.
/// </copyright>
/// <version>1.0.0</version>
public partial class admin_Logs_Create : PageBase
{
    public admin_Logs_Create()
    {
        //设置权限，使未登录用户不能访问该页
        authentication = Constants.AUTHENTICATION_ADMIN;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    /// <summary>
    /// Logout
    /// </summary>
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        AuthenticationService authenticationService = new AuthenticationService();
        authenticationService.LogOut();
        Response.Redirect(Request.UrlReferrer.ToString());
    }

    /// <summary>
    /// 进行新建操作
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LinkButton2_Click(object sender, EventArgs e)
    {

        string title = HTMLFilter.Strip(TextBox_Title.Text.Trim());
        string content = Helper.FiltScriptAndStyle(FCKeditor1.Value);
        string userIp = Request.UserHostAddress;
        long actionId = Convert.ToInt64(Request.QueryString["actionId"]);

        EditService es = new EditService();

        try
        {
            es.CreateLogs(title, content, userIp, actionId);

            //新建成功，弹出提示
            Message.Text = "Create Log Successfully";
            popupCmd.Text = "<script type='text/javascript'>$('.popup').css('display', 'block');$('#alpha').css('display', 'block')</script>";
            //window.location.href='admin_Logs_View.aspx?actionId=" + actionId.ToString() + 
        }
        catch
        {
            //新建失败，弹出提示
            Message.Text = "Create Log Failed";
            popupCmd.Text =
                "<script type='text/javascript'>$('.popup').css('display', 'block');$('#alpha').css('display', 'block');</script>";
        }
    }
}
